import Mock from 'mockjs'


const data = Mock.mock({
  'list|1000': [{
    "url": "@image(100x100, @color)",
    "title": "@ctitle",
    "id": "@id",
    "desc": "@cword(20,30)",
    "price|10-1000": 1
  }]
})


Mock.mock('/api/list', 'post', (req) => {
  const { pageCode = 1, pageSize = 10 } = JSON.parse(req.body)

  const list = data.list.slice((pageCode - 1) * pageSize, pageCode * pageSize)

  return {
    code: 200,
    data: list
  }
})
